#!/usr/bin/env python
# -*- encoding: utf-8 -*-
# Project: spd-sxmcc
"""
@author: lyndon
@time Created on 2019/2/27 15:15
@desc
"""
from com.bratislava import DbPoolUtil
if __name__ == "__main__":
    # 使用demo，工作目录在项目目录的前提下,使用表为TEST2表
    dbpool_util = DbPoolUtil(db_type="mysql")

    a = input(">>>")

    # sql1 = """DELETE FROM TEST2"""
    # result1 = dbpool_util.execute_iud(sql1)
    # print(result1)
    #
    # # mysql和mssql语句的参数使用%s作为占位符，oracle和sqlite使用:数字作为占位符(sqllite还可以用?作为占位符)
    # # hbase插入语句的参数使用:数字或者?作为占位符,hbase的INSERT请使用UPSERT替换
    # sql2 = """INSERT INTO TEST2(id,name) VALUES (%s,%s)"""
    # sql2 = """INSERT INTO TEST2(id,name) VALUES (:1,:2)"""
    # sql2 = """UPSERT INTO TEST2(id,name) VALUES (?,?)"""
    # test_args2 = [(1, '王'), (2, '葬爱'), (3, 'shao'), (5, 'nian'), (8, 'wang')]
    # result2 = dbpool_util.execute_many_iud(sql2, test_args2)
    # print(result2)
    #
    # sql3 = """SELECT id as wangleai,name as zangai FROM TEST2 """
    # result3 = dbpool_util.execute_query(sql3)
    # print(result3)
    # result3 = dbpool_util.execute_query_single(sql3)
    # print(result3)
    # result3 = dbpool_util.execute_query(sql3, dict_mark=True)
    # print(result3)
    # result3 = dbpool_util.execute_query_single(sql3, dict_mark=True)
    # print(result3)
    # dbpool_util.loop_row_custom(sql3)

# 此处反射调用相关方法，文件就不给了，嫌麻烦
# from util.ClassTest import ClsTest
#  cla_test = ClsTest()
# dbpool_util.loop_row(cla_test, "print_row", sql3)

# import util.ModuleTest as mod_test
#
# dbpool_util.loop_row(mod_test, "print_row", sql3)
#
# sql4 = """SELECT id,name FROM TEST2 where id = %s"""
# sql4 = """SELECT id,name FROM TEST2 where id = :1"""
# test_args4 = (3,)
# result4 = dbpool_util.execute_query(sql4, args=test_args4)
# print(result4)
